﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Kea
{

    public class DataPlanOrdered<T> : DataPlanBaseTRW<T> where T : TableReaderWriter<T>, new()
    {
        internal DataPlanOrdered() { }
        private DataPlanOrdered<T> ThenByPrivate<TKey>(Func<T, TKey> keySelector, bool isAssending)
        {
            KeyComparerProvider<T> comparer = new KeyComparerProvider<T, TKey>(Comparer, keySelector, isAssending);
            return new DataPlanOrdered<T>()
            {
                Filters = Filters,
                Comparer = comparer,
                IndexName = IndexName,
                IndexValuesLowerLimit = IndexValuesLowerLimit,
                IndexValuesUpperLimit = IndexValuesUpperLimit
            };
        }

        public DataPlanOrdered<T> ThenBy<TKey>(Func<T, TKey> keySelector)
        {
            return ThenByPrivate(keySelector, true);
        }
        public DataPlanOrdered<T> ThenByDescending<TKey>(Func<T, TKey> keySelector)
        {
            return ThenByPrivate(keySelector, false);
        }
    }
}
